﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace AutoClub.Core
{
    /// <summary>
    /// Base entity for all entities model
    /// </summary>
    /// <typeparam name="TId"></typeparam>
    public abstract class BaseEntity<TId>
        where TId : struct
    {
        #region Constructor

        public BaseEntity()
        {
            this.Id = default(TId);
        }

        #endregion

        /// <summary>
        /// Identifier for an entity
        /// </summary>
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public virtual TId Id { get; internal set; } //el set no puede ser privado porque las migrations no andan

        /// <summary>
        /// Identifies the state of this entity
        /// </summary>
        [Required]
        public bool Active { get; set; }

        /// <summary>
        /// Identifies who create this entity
        /// </summary>
        [Required]
        public string CreatedBy { get; set; }

        /// <summary>
        /// Identifies when was this entity created
        /// </summary>
        [Required]
        public DateTimeOffset CreatedOn { get; set; }
    }
}
